﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="NhapHoaDonBanHangShowRoom.ascx.cs" Inherits="WebUserControl_NhapHoaDonBanHangShowRoom" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register assembly="newWindow" namespace="newWindow" tagprefix="cc1" %>
<%@ Register Assembly="CSharp_MessageBox" Namespace="CSharp_MessageBox" TagPrefix="CS_Msg" %>
<%@ Import Namespace="BCDataCenter" %>

<%@ Register src="uscMsgBox.ascx" tagname="uscMsgBox" tagprefix="uc1" %>
<link rel="stylesheet" href='<%=ResolveUrl("~/LayoutCss/datePicker.css")%>' type="text/css" />
<script type="text/javascript"  src='<%=ResolveUrl("~/JScript/jquery.alphanumeric.js")%>'></script>
<link rel="stylesheet" href='<%=ResolveUrl("~/LayoutCss/K_BaoCaoFormLayout.css")%>' type="text/css" />



<style type="text/css">
        .AutoExtender
        {
            font-family: Verdana, Helvetica, sans-serif;
            font-size: .8em;
            font-weight: normal;
            border: solid 1px #006699;
            line-height: 20px;
            padding: 10px;
            background-color: White;
            margin-left:10px;
            width: 300px;
        }
        .AutoExtenderList
        {
            border-bottom: dotted 1px #006699;
            cursor: pointer;
            color: Maroon;
        }
        .AutoExtenderHighlight
        {
            color: White;
            background-color: #006699;
            cursor: pointer;
        }
        #divwidth
        {
         width: auto !important;    
        }
        #divwidth div
       {
        width: auto !important;   
       }
       #divwidthMaHangInput
       {
       	width: auto !important;  
       }
        #divwidthMaHangInput div
       {
       	width: auto !important;  
       } 
       
 </style>

<script type="text/javascript">
    function PrintedOrder() {            
        window.open('Print.aspx', 'PrintMe', 'height=900px,width=900px,scrollbars=1');        
    }
    function SetTarget() {

        document.forms[0].target = "_blank";

    } 
     function pageLoad() {
     
            $("#<%= txtChietKhau.ClientID %>").numeric({allow:"."});
            
              $("#<%= btnNew.ClientID %>").click(function() { 
        $.blockUI({
             message: '<h1>Xin vui lòng chờ xử lý</h1>', 
            css: { 
            border: 'none', 
            padding: '15px', 
            backgroundColor: '#f00', 
            opacity: .5, 
            color: '#fff' 
        } }); 
        }); 
            
              $("#<%= btnSave.ClientID %>").click(function() { 
        $.blockUI({
             message: '<h1>Xin vui lòng chờ xử lý</h1>', 
            css: { 
            border: 'none', 
            padding: '15px', 
            backgroundColor: '#f00', 
            opacity: .5, 
            color: '#fff' 
        } }); 
        }); 
        
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
                function EndRequestHandler(sender, args) {
                        $.unblockUI();
                }
     }
   
    
</script>

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" RenderMode="Block" >
    <ContentTemplate>
    <fieldset>
    <legend>Nhập hóa đơn bán hàng</legend>
    </fieldset>
            <asp:Panel ID="Panel4" runat="server" BackColor="#EBEBEB" 
                        BorderStyle="None" Height="33px" Width="100%">
                 <asp:ImageButton ID="btnNew" runat="server" Width="25px" Height="25px" ToolTip="Tạo hóa đơn mới" 
                    ImageUrl="~/WebMaster/Images/Document.png" onclick="btnNew_Click" />
                &nbsp;
                <asp:ImageButton ID="btnSave" runat="server" Width="25px" Height="25px" ToolTip="Lưu hóa đơn"
                    ImageUrl="~/WebMaster/Images/Save.png" onclick="btnSave_Click" /> 
                &nbsp;  
                <asp:ImageButton ID="btnApKhuyenMai" runat="server" Width="25px" Height="25px" ToolTip="Áp khuyến mãi"
                    ImageUrl="~/WebMaster/Images/Symbol-Check.png" onclick="btnApKhuyenMai_Click" /> 
                   &nbsp; 
                <asp:ImageButton ID="btnDelete" runat="server" Width="25px"  Height="25px" ToolTip="Xóa khuyến mãi"
                    ImageUrl="~/WebMaster/Images/Symbol-Delete.png" Visible="false" onclick="btnDelete_Click" /> 
                            
                 <asp:ImageButton ID="CapNhatGia" runat="server" ToolTip ="Cập nhật giá" 
                     Width="25px" ImageUrl="~/image/Symbol-Refresh.png" onclick="ImageButton1_Click" Visible="False" />
            </asp:Panel>
            <br />
           <cc1:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" 
            BackColor="#CCFFFF" Font-Names="Arial"  Height="720px" 
            Width="850px">
            
            <cc1:TabPanel ID="TabPanel1" runat="server" HeaderText="Nhập thông tin" TabIndex="0">
                <ContentTemplate>            
               
               <fieldset>                  
                    <div class="fm-req">
                       <label for="txtMaTuVanVien">Số HĐ:</label>
                       <asp:TextBox ID="txtSoHD" runat="server" Width="100px" BackColor="Yellow" 
                            ReadOnly="True"></asp:TextBox>

                    </div>
                    <div class="fm-req">
                       <label for="txtMaTuVanVien">Ngày HĐ:</label>
                       <asp:TextBox ID="txtNgayHD" runat="server" Width="100px" 
                            OnTextChanged="txtNgayHD_TextChanged" AutoPostBack="True"></asp:TextBox>

                    </div>
                    <div class="fm-req">
                       <label for="txtMaTuVanVien">Mã khách hàng:</label>
                       <asp:TextBox ID="txtMaTVV" runat="server" AutoPostBack="True" 
                            OnTextChanged="txtMaTVV_TextChanged" Width="100px" ></asp:TextBox>

                       
                         <div id="divwidth" style="overflow:scroll; height:150px;display:none"></div>
            <cc1:AutoCompleteExtender CompletionSetCount="12"
            CompletionInterval="10" 
            MinimumPrefixLength="1" 
            ServiceMethod="GetTTKhachHang"
            TargetControlID="txtMaTVV"
            ServicePath="~/Services/WebServiceNhapHoaDonBanHang.asmx"
            ID="AutoCompleteExtender1" 
            runat="server" CompletionListItemCssClass="AutoExtenderList"
             DelimiterCharacters="" Enabled="True" 
             CompletionListHighlightedItemCssClass="AutoExtenderHighlight"
             CompletionListElementID="divwidth" 
            CompletionListCssClass="AutoExtender"></cc1:AutoCompleteExtender>
              
                       <asp:TextBox ID="txtHoTen" runat="server" Width="200px"></asp:TextBox>

                    </div>
                    <div class="fm-req">
                       <label for="txtMaTuVanVien">Thông tin khách hàng:</label>
                       <asp:TextBox ID="txtThongTinTVV" runat="server" Width="300px"></asp:TextBox>

                    </div>
                    <div class="fm-req">
                       <label for="txtMaTuVanVien">Chiết khấu %:</label>
                       <asp:TextBox ID="txtChietKhau" runat="server" Width="120px"></asp:TextBox>
<span><b>%</b></span>
                    </div>
                
                    <div class="fm-re">
                        <label for="txtMaTuVanVien">Doanh số trong tháng:</label>
                       <asp:TextBox ID="txtDSTrongThang" ReadOnly="True" BackColor="Yellow" 
                            runat="server" Width="150px"></asp:TextBox>

                       </div>
                    <div class="fm-re">      
                       <label for="txtMaTuVanVien">Doanh số toàn nhóm:</label>
                       <asp:TextBox ID="txtDSTN" ReadOnly="True" BackColor="Yellow" runat="server" 
                            Width="150px"></asp:TextBox>

                       </div>
                    <div class="fm-re">
                        <label for="txtMaTuVanVien">Số BA:</label>
                       <asp:TextBox ID="txtSoBA" ReadOnly="True" BackColor="Yellow" runat="server" 
                            Width="150px"></asp:TextBox>

                </div>                             
               </fieldset>                         
            <br />
                      <asp:GridView ID="gvChiTietDonHang" runat="server" AutoGenerateColumns="False"
                                Width="100%" onrowcommand="gvChiTietDonHang_RowCommand" 
                                    onrowcreated="gvChiTietDonHang_RowCreated" ShowFooter="True" 
                                    OnRowEditing="gvChiTietDonHang_RowEditing"
                                    OnRowCancelingEdit="gvChiTietDonHang_RowEditingRowCancelingEdit"
                                    OnRowUpdating="gvChiTietDonHang_RowUpdating"
                                    OnRowDeleting="gvChiTietDonHang_RowDeleting" 
                        EnableModelValidation="True"><Columns>
<asp:TemplateField HeaderText="STT">
    <EditItemTemplate>
 
                                            <asp:Label ID="lblSTT" runat="server" Text='<%# Bind("STT") %>'></asp:Label>
                                        
</EditItemTemplate>
<ItemTemplate>
 
                                            <asp:Label ID="lblSTT" runat="server" Text='<%# Bind("STT") %>'></asp:Label> 
                                        
</ItemTemplate>

<HeaderStyle HorizontalAlign="Center"></HeaderStyle>

<ItemStyle Width="15px" HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Loại dòng">
    <EditItemTemplate>
                                            <asp:TextBox ID="txtLoaiDongEdit" runat="server" Text='<%# Bind("LoaiDong") %>' 
                                                Width="97%" AutoPostBack="true" OnTextChanged="txtLoaiDongEdit_TextChanged"></asp:TextBox>
                                                <div id="divwidthDong" style="overflow:scroll; height:150px;display:none"></div>
                                                <cc1:AutoCompleteExtender ID="txtLoaiDongEdit_AutoCompleteExtender" 
                                                runat="server"
                                                ServiceMethod="GetListLoaiDong" ServicePath="~/Services/WebServiceNhapHoaDonBanHang.asmx" 
                                                TargetControlID="txtLoaiDongEdit"
                                                MinimumPrefixLength="1" 
                                                CompletionInterval="10"
                                                EnableCaching="True"
                                                CompletionSetCount="12" 
                                                UseContextKey="true"                                                                           
                                                CompletionListCssClass="AutoExtender"
                                                CompletionListItemCssClass="AutoExtenderList"
                                                CompletionListHighlightedItemCssClass="AutoExtenderHighlight"
                                                CompletionListElementID="divwidthDong">
                                            </cc1:AutoCompleteExtender>
                                           
                                        
</EditItemTemplate>
<FooterTemplate>
                                            <asp:TextBox ID="txtLoaiDongInput" runat="server" Width="97%" AutoPostBack="true" TabIndex="5" OnTextChanged="txtLoaiDongInput_TextChanged"></asp:TextBox>
                                              <div id="divwidthDongInput" style="overflow:scroll; height:150px;display:none"></div>
                                            <cc1:AutoCompleteExtender ID="txtLoaiDongInput_AutoCompleteExtender" 
                                                runat="server"
                                                ServiceMethod="GetListLoaiDong" ServicePath="~/Services/WebServiceNhapHoaDonBanHang.asmx" 
                                                TargetControlID="txtLoaiDongInput"
                                                MinimumPrefixLength="1" 
                                                CompletionInterval="10"
                                                EnableCaching="True"
                                                CompletionSetCount="12"
                                                UseContextKey="true"                                                                           
                                                CompletionListCssClass="AutoExtender"
                                                CompletionListItemCssClass="AutoExtenderList"
                                                CompletionListHighlightedItemCssClass="AutoExtenderHighlight"
                                                CompletionListElementID="divwidthDongInput">
                                            </cc1:AutoCompleteExtender>                                            
                                        
</FooterTemplate>
<ItemTemplate>
                                            <asp:Label ID="lblLoaiDong" runat="server" 
                                                Text='<%# Bind("LoaiDong") %>'></asp:Label>
                                        
</ItemTemplate>

<FooterStyle VerticalAlign="Top" />

<ItemStyle Width="70px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Mã hàng">
    <EditItemTemplate>
                                            <asp:TextBox ID="txtMaHangEdit" runat="server" Text='<%# Bind("MaHang") %>' 
                                                Width="97%" AutoPostBack="true" OnTextChanged="txtMaHangEdit_TextChanged"></asp:TextBox>
                                                 <div id="divwidthMaHangEdit" style="overflow:scroll; height:150px;display:none"></div>
                                                <cc1:AutoCompleteExtender ID="txtMaHangEdit_AutoCompleteExtender" 
                                                runat="server"
                                                ServiceMethod="GetMatHangInfo" ServicePath="~/Services/WebServiceNhapHoaDonBanHang.asmx" 
                                                TargetControlID="txtMaHangEdit"
                                                MinimumPrefixLength="1" 
                                                CompletionInterval="10"
                                                EnableCaching="True"
                                                CompletionSetCount="12"                             
                                                CompletionListCssClass="AutoExtender"
                                                CompletionListItemCssClass="AutoExtenderList"
                                                CompletionListHighlightedItemCssClass="AutoExtenderHighlight"
                                                CompletionListElementID="divwidthMaHangEdit">
                                            </cc1:AutoCompleteExtender>
                                        
</EditItemTemplate>
<FooterTemplate>
                                            <asp:TextBox ID="txtMaHangInput" runat="server" Width="97%" AutoPostBack="true" TabIndex="5" OnTextChanged="txtMaHangInput_TextChanged"></asp:TextBox>
                                            <div id="divwidthMaHangInput" style="overflow:scroll;height:150px;display:none"></div>
                                            <cc1:AutoCompleteExtender ID="txtMaHangInput_AutoCompleteExtender" 
                                                runat="server"
                                                ServiceMethod="GetMatHangInfo" ServicePath="~/Services/WebServiceNhapHoaDonBanHang.asmx" 
                                                TargetControlID="txtMaHangInput"
                                                MinimumPrefixLength="1" 
                                                CompletionInterval="10"
                                                EnableCaching="True"
                                                CompletionSetCount="12"                             
                                                CompletionListCssClass="AutoExtender"
                                                CompletionListItemCssClass="AutoExtenderList"
                                                CompletionListHighlightedItemCssClass="AutoExtenderHighlight"
                                                CompletionListElementID="divwidthMaHangInput">
                                            </cc1:AutoCompleteExtender>
                                                                                   
                                        
</FooterTemplate>
<ItemTemplate>
                                            <asp:Label ID="lblMaHang" runat="server" Text='<%# Bind("MaHang") %>'></asp:Label>
                                        
</ItemTemplate>

<FooterStyle VerticalAlign="Top" />

<ItemStyle Width="70px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Tên hàng">
    <EditItemTemplate>
                                            <asp:TextBox ID="txtTenHangEdit" runat="server" Text='<%# Bind("TenHang") %>' ReadOnly="true" Width="97%"></asp:TextBox>
                                        
</EditItemTemplate>
<FooterTemplate>
                                            <asp:TextBox ID="txtTenHangInput" runat="server" Width="97%" ReadOnly="true"></asp:TextBox>                                            
                                        
</FooterTemplate>
<ItemTemplate>
                                            <asp:Label ID="lblTenHang" runat="server" Text='<%# Bind("TenHang") %>'></asp:Label>
                                        
</ItemTemplate>

<FooterStyle VerticalAlign="Top" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Số lượng">
    <EditItemTemplate>
                                            <asp:TextBox ID="txtSoLuongEdit" runat="server" Width="97%" AutoPostBack="true"
                                                Text='<%# Bind("SoLuong") %>' OnTextChanged="txtSoLuongEdit_TextChanged"></asp:TextBox>
                                        
</EditItemTemplate>
<FooterTemplate>
                                            <asp:TextBox ID="txtSoLuongInput" runat="server" AutoPostBack="True" 
                                                ontextchanged="txtSoLuongInput_TextChanged" Width="97%"></asp:TextBox>
                                        
</FooterTemplate>
<ItemTemplate>
                                            <asp:Label ID="lblSoLuong" runat="server" Text='<%# Eval("SoLuong") %>'></asp:Label>
                                        
</ItemTemplate>

<FooterStyle VerticalAlign="Top" />

<ItemStyle Width="40px" />
</asp:TemplateField>
<asp:BoundField DataField="Gia" HeaderText="Gia" Visible="False" />
<asp:BoundField DataField="VAT" HeaderText="VAT" Visible="False" />
<asp:BoundField DataField="ThanhTien" HeaderText="ThanhTien" Visible="False" />
<asp:TemplateField HeaderText="Sửa">
    <EditItemTemplate>
                                        <div align="right">
                                            <asp:LinkButton ID="LinkButtonUpdate" runat="server"
                                                CausesValidation="True" CommandName="Update">
                                                <asp:Image ID="imgUpdate" runat="server"
                                                    ImageUrl="../WebMaster/Images/Save16.png"
                                                    AlternateText="Lưu" />
                                            </asp:LinkButton>
                                            <asp:LinkButton ID="LinkButtonCancel" runat="server"
                                                CausesValidation="False" CommandName="Cancel">
                                                <asp:Image ID="imgCancel" runat="server"
                                                     ImageUrl="../WebMaster/Images/Cancel16.jpg"
                                                     AlternateText="Hủy bỏ" />
                                            </asp:LinkButton>
                                        </div>
                                        
</EditItemTemplate>
<FooterTemplate>
                                        <div align="right">
                                            <asp:LinkButton ID="btnAddRow" runat="server" 
                                                CausesValidation="true" CommandName="Insert" 
                                                OnClick="btnAddRow_Click" >
                                                <asp:Image ID="imgInsert" runat="server" 
                                                     ImageUrl="../WebMaster/Images/New File16.png" 
                                                     AlternateText="Thêm" />
                                            </asp:LinkButton>
                                        </div>
                                        
</FooterTemplate>
<ItemTemplate>
                                        <div align="right">
                                            <asp:LinkButton ID="LinkButtonEdit" runat="server" 
                                                CausesValidation="False" CommandName="Edit">
                                                <asp:Image ID="imgEdit" runat="server"
                                                     ImageUrl="../WebMaster/Images/small_edit.png"
                                                     AlternateText="Sửa" />
                                            </asp:LinkButton>
                                        </div>
                                        
</ItemTemplate>

<FooterStyle VerticalAlign="Top" />

<HeaderStyle Width="16px" HorizontalAlign="Center" />

<ItemStyle Width="20px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Xóa">
    <ItemTemplate>
                                            <asp:LinkButton ID="linkbntDelete" runat="server" 
                                                CausesValidation="False" CommandName="Delete">
                                                <asp:Image ID="imgDelete" runat="server"
                                                     ImageUrl="../WebMaster/Images/delete.gif"
                                                     AlternateText="Xóa" />
                                            </asp:LinkButton>
                                        
</ItemTemplate>

<HeaderStyle HorizontalAlign="Center" Width="20px"></HeaderStyle>

<ItemStyle Width="20px" />
</asp:TemplateField>
</Columns>
</asp:GridView>
     
                         
                           
                            <asp:Label ID="Label1" runat="server" Text="Tổng tiền "></asp:Label>

                            <asp:TextBox ID="txtTongTien" runat="server" Width="200px" 
                        ReadOnly="True" Font-Bold="True" ForeColor="Red"></asp:TextBox>

                       
                        
             
</ContentTemplate>
            
</cc1:TabPanel>
            
            <cc1:TabPanel ID="TabPanel2" runat="server" HeaderText="Tìm kiếm đơn hàng chưa in" TabIndex="1">
                <ContentTemplate>
            
                           <asp:GridView ID="gvDonHangChuaIn" runat="server" AutoGenerateColumns="False" OnRowCommand="gvDonHangChuaIn_RowCommand">
                                <Columns>
                                    <asp:TemplateField HeaderText="In ?">
                                        <ItemTemplate>
                                            <asp:ImageButton Width="20px" Height="20px" ID="bntPrint" runat="server" CommandName="btnPrinted" 
                                                ImageUrl="~/WebMaster/Images/Printer.png" />                                                                                   
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField DataField="MaHD" HeaderText="Số ĐH" />
                                    <asp:BoundField DataField="TenTVV" HeaderText="Tư vấn viên" />
                                    <asp:BoundField DataField="TienHD" HeaderText="Tiền ĐH" DataFormatString="{0:###,###.###}" />
                                    <asp:BoundField DataField="TienHD" HeaderText="Thanh toán" DataFormatString="{0:###,###.###}" />
                                    <asp:TemplateField HeaderText="Chọn">
                                        <ItemTemplate>
                                            <asp:LinkButton ID="btnSelect" runat="server" CommandName="Selected">Chọn</asp:LinkButton> 
                                        </ItemTemplate>
                                    </asp:TemplateField>                                    
                                </Columns>
                            </asp:GridView>                            
                                              
                 
</ContentTemplate>
            
</cc1:TabPanel>
            
       </cc1:TabContainer>
    <uc1:uscMsgBox ID="uscMsgBox1" runat="server" />
    </ContentTemplate>
     
</asp:UpdatePanel>

